package com.zhigongtech.core.web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import com.google.common.base.Predicates;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@Profile({"test","dev"})
public class SwaggerConfiguration {

	@Bean
    public Docket restApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .paths(Predicates.and(PathSelectors.ant("/**"), Predicates.not(PathSelectors.ant("/error"))))
                .build();
    }
	 
	@Bean
	public Docket createRestApi() {
		return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).groupName("系统权限模块").select()
				.apis(RequestHandlerSelectors.basePackage("com.zhigongtech.tender.rest.sys.controller")).paths(PathSelectors.any())
				.build();
	}

	private ApiInfo apiInfo() {
		return new ApiInfoBuilder().title("中化石油原油线上采购招标平台").description("中化石油原油线上采购招标平台 RESTful APIs")
				.termsOfServiceUrl("http://www.zhigongtech.com/").contact(new Contact("zhigongtech","http://www.zhigongtech.com/","lanjiangfei@zhigongtech.com")).version("1.0").build();
	}
}
